-
Notifications
You must be signed in to change notification settings - Fork 592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(java-binding): generate jni method signature with macro #12487
Conversation
Codecov Report
@@ Coverage Diff @@
## main #12487 +/- ##
==========================================
+ Coverage 69.42% 69.71% +0.29%
==========================================
Files 1429 1426 -3
Lines 238628 236310 -2318
==========================================
- Hits 165666 164752 -914
+ Misses 72962 71558 -1404
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 104 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
src/jni_core/src/lib.rs
Outdated
let read_plan = Message::decode(to_guarded_slice(&read_plan, env)?.deref())?; | ||
let iter = RUNTIME.block_on(HummockJavaBindingIterator::new(read_plan))?; | ||
Ok(iter.into()) | ||
#[cfg(madsim)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does #[cfg_or_panic(not(madsim))]
work here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to know that there is such a useful macro. Thanks for the suggestion!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! These macros are amazing! Maybe we can remove
the prefix Java_com_risingwave_java_binding_Binding_
so that we can have the same native method names in Rust.
Find a crate for this -> https://crates.io/crates/jni_fn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Just had a look at the crate. It aims to convert the method name to a name that is able to automatically recognized by jvm when loading the dynamic library. However, in this PR, we have changed to register the native methods manually instead of via a predefined name mapping rule, and therefore it's unnecessary for us to maintain the method name according to the rule with the macro in the crate. |
…2123) feat(java-binding): generate jni method signature with macro (#12487) feat(streaming): recover `no_shuffle_backfill` (#12493) feat(test): support customized source logic in deterministic test (#12456) refactor(storage): reorg selector (#12392) feat(frontend): add rw_catalog.rw_hummock_sstables (#12532) chore: bump risingwave version in docker compose to 1.2.0 (#12530) Signed-off-by: Bugen Zhao <[email protected]> refactor(sink): decouple sink formatter and payload writer (#12515) chore(java-binding): refine stream chunk benchmark (#12504) feat(meta): add create_type to `Table` (#12529) refactor(sink): refine sink trait and macro (#12478) refactor(backup): refine error message (#12388) feat(sink): turn sink writer into higher level log sinker (#12152) fix(over window): don't expect stream keys in UpdateDelete and UpdateInsert the same (#12536) Signed-off-by: Richard Chien <[email protected]> refactor(expr): separate function implementations into a new crate (#12485) Signed-off-by: Runji Wang <[email protected]> fix(config): make metrics_level opt backward compatible (#12541) refactor(connector): replace sink writer rpc with jni (#12480) refactor(connector): remove `WriteGuard` and `fulfill_meta_column` from parser (#12542) Signed-off-by: Bugen Zhao <[email protected]> feat(sink): handle stream key sink pk mismatch (#12458) feat(optimizer): support apply hop window transpose rule (#12338)
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
In this PR, we implement a macro
gen_jni_sig
that generates the jni signature from the java method signature. With this macro, we can avoid manually write the list of jni native and signature list when we register native method.Besides, since we provide a register native function, in the java binding dynamic library, we don't have to export each jni method one by one. We change to provide a single method
JNI_OnLoad
, which will be called and register the jni method when the dynamic library is loaded.Checklist
./risedev check
(or alias,./risedev c
)Documentation
Release note
If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.